import {getDocument, getDocumentById} from "@/api/document";

const getDefaultState = () => {
    return {};
};

const state = getDefaultState();

const mutations = {};

const actions = {
    //按植物ID查询
    async getDocument({state}, doc) {
        return new Promise((resolve, reject) => {
            getDocument(doc).then(response => {
                if (response.success) {
                    resolve(response.data);
                } else {
                    reject(response);
                }
            });
        });
    },
    //按文献ID查询
    async getDocumentById({state}, id) {
        return new Promise((resolve, reject) => {
            getDocumentById(id).then(response => {
                if (response.success) {
                    resolve(response.data);
                } else {
                    reject(response);
                }
            });
        });
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions
};
